package il.ac.tau.cg.ex3.entities.styles.drawables;

import il.ac.tau.cg.ex3.entities.styles.Color;

public class CheckersDrawable implements Drawable
{
	private double size;
	
	private Color color1;
	private Color color2;
	
	public CheckersDrawable(double size, Color color1, Color color2)
	{
		this.size = size;
		
		this.color1 = color1;
		this.color2 = color2;
	}
	
	@Override
	public Color sample(double x, double y)
	{
		int sx = (int)(x / size);
		int sy = (int)(y / size);
		
		return ((sx + sy) % 2 == 0) ? color1.clone() : color2.clone();
	}
}
